package utils;

import jxta.security.exceptions.CryptoException;
import net.jxta.peergroup.PeerGroupFactory;
import net.jxta.exception.PeerGroupException;
import net.jxta.impl.peergroup.Platform;
import net.jxta.impl.peergroup.GenericPeerGroup;
import net.jxta.peergroup.PeerGroup;

public class Example1 {
    static PeerGroup netPeerGroup = null;
     public static void main(String args[]) {
       Example1 myapp = new Example1();
       System.out.println ("Launching JXTA");
       myapp.launchJXTA();
       myapp.getJXTAInfo();
       System.out.println ("Terminating Application");
       System.exit(0);
     }
     /*
      * Default Constructor
    */
     public void Example1() {
    }
    /*
     * Private method for starting the JXTA platform.
    */
    private void launchJXTA() {
    	   try {
    		      netPeerGroup = PeerGroupFactory.newNetPeerGroup();
    		   } catch (PeerGroupException e) {
    		        System.out.println("Unable to create PeerGroup - Failure");
    		        e.printStackTrace();
    		        System.exit(1);
    		    }

    }
    public void getJXTAInfo() {
    	   System.out.println("This Peer’s ID in the group : " +
    	netPeerGroup.getPeerID().toString());
    	       System.out.println("This Peer’s Name in the group : " +
    	netPeerGroup.getPeerName());
    	       System.out.println("The Peergroup’s ID : " +
    	netPeerGroup.getPeerGroupID().toString());
    	       System.out.println("The Peergroup’s name : " +
    	netPeerGroup.getPeerGroupName());
    	    }

 }
